package com.eastfair.matching.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eastfair.annotation.annotation.log.SysLog;
import com.eastfair.boot.request.PageParams;
import com.eastfair.core.base.R;
import com.eastfair.matching.service.MatchingWorkOrderService;
import com.eastfair.venueservice.dto.WorkOrderDTO;
import com.eastfair.venueservice.dto.WorkOrderOperationRecordDTO;
import com.eastfair.venueservice.dto.WorkOrderQuery;
import com.eastfair.venueservice.vo.WorkOrderVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * 工单
 * </p>
 *
 * @author ln
 * @date 2022-10-24
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/workOrder")
@Api(value = "workOrder", tags = "工单")
public class MatchingWorkOrderController {


    @Autowired
    private MatchingWorkOrderService matchingWorkOrderService;




    /**
     * 修改派工单.
     *
     * @param workOrderDTO workOrderDTO
     * @return the r
     */
    @PostMapping("/updateWorkOrder")
    @SysLog("修改派工单")
    public R<Boolean> updateWorkOrder(@RequestBody WorkOrderDTO workOrderDTO){
        return R.success(matchingWorkOrderService.updateWorkOrder(workOrderDTO));
    }

    /**
     * 查询派工单.
     *
     * @param workOrderQuery workOrderQuery
     * @return the r
     */
    @PostMapping("/queryWorkOrder")
    public R<Page<WorkOrderVO>> queryWorkOrder(@RequestBody PageParams<WorkOrderQuery> workOrderQuery){
        return R.success(matchingWorkOrderService.queryWorkOrder(workOrderQuery));
    }

    /**
     * 查询派工单明细.
     *
     * @param workOrderQuery workOrderQuery
     * @return the r
     */
    @PostMapping("/queryWorkOrderDetail")
    public R<WorkOrderVO> queryWorkOrderDetail(@RequestBody WorkOrderQuery workOrderQuery){
        return R.success(matchingWorkOrderService.queryWorkOrderDetail(workOrderQuery));
    }

    /**
     * 接收工单.
     *
     * @param workOrderOperationRecordDTO workOrderOperationRecordDTO
     * @return the r
     */
    @PostMapping("/receiveWorkOrder")
    @SysLog("接收工单")
    public R<Boolean> receiveWorkOrder(@RequestBody WorkOrderOperationRecordDTO workOrderOperationRecordDTO){
        return R.success(matchingWorkOrderService.receiveWorkOrder(workOrderOperationRecordDTO));
    }

    /**
     * 撤销工单.
     *
     * @param workOrderOperationRecordDTO workOrderOperationRecordDTO
     * @return the r
     */
    @PostMapping("/revokeWorkOrder")
    @SysLog("撤销工单")
    public R<Boolean> revokeWorkOrder(@RequestBody WorkOrderOperationRecordDTO workOrderOperationRecordDTO){
        return R.success(matchingWorkOrderService.revokeWorkOrder(workOrderOperationRecordDTO));
    }

    /**
     * 作废工单.
     *
     * @param workOrderOperationRecordDTO workOrderOperationRecordDTO
     * @return the r
     */
    @PostMapping("/cancelWorkOrder")
    @SysLog("作废工单")
    public R<Boolean> cancelWorkOrder(@RequestBody WorkOrderOperationRecordDTO workOrderOperationRecordDTO){
        return R.success(matchingWorkOrderService.cancelWorkOrder(workOrderOperationRecordDTO));
    }

    /**
     * 完结工单.
     *
     * @param workOrderOperationRecordDTO workOrderOperationRecordDTO
     * @return the r
     */
    @PostMapping("/closeWorkOrder")
    @SysLog("完结工单")
    public R<Boolean> closeWorkOrder(@RequestBody WorkOrderOperationRecordDTO workOrderOperationRecordDTO){
        return R.success(matchingWorkOrderService.closeWorkOrder(workOrderOperationRecordDTO));
    }



}
